package com.srd.phone.activity;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.ImageView;

import com.shengrongdai.srd.R;

public class  AgreementDialog extends Dialog implements View.OnClickListener {

    private Context mContext;
    private OnCallBack mOnCallBack;

    private Button btn_ok;
    private ImageView iv_close;

    public AgreementDialog(Context context, OnCallBack onCallBack) {
        super(context, R.style.dialog1);
        this.mContext = context;
        this.mOnCallBack = onCallBack;
        show();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_agreement_layout);


        WebView wView = (WebView)findViewById(R.id.webview);

        WebSettings wSet = wView.getSettings();
        wSet.setJavaScriptEnabled(true);

        wView.loadUrl("file:///android_asset/agreement.html");


        btn_ok = (Button)findViewById(R.id.btn_ok);
        btn_ok.setOnClickListener(this);

        iv_close = (ImageView)findViewById(R.id.iv_close);
        iv_close.setOnClickListener(this);

    }


    @Override
    public void onClick(View v) {

        switch (v.getId()) {
            case R.id.btn_ok:
                if (mOnCallBack != null)
                    mOnCallBack.onClick(true);
                dismiss();
                break;

            case R.id.iv_close:
                if (mOnCallBack != null)
                    mOnCallBack.onClick(false);
                dismiss();
                break;
        }
    }

    @Override
    public void dismiss(){
        super.dismiss();
    }

    public interface OnCallBack {
        void onClick(boolean bool);
    }
}


